<template>
  <!-- 变更记录 -->
  <!-- <AdvancedTable
  :autoResize="true"
  :columns="TABLE_COLUMNS"
  :dataSource="listData" /> -->
  <basic-table
    :showSelectCol="false"
    :loading="tableInfo.loading"
    :columns="tableInfo.columns"
    :dataSource="tableInfo.list"
    :pagination="pagination"
    :tableHeight="460"
    @pageChange="handlePageChange"
    @pageSizeChange="handlePageSizeChange" />
</template>

<script>
import { mapState } from 'vuex';
import BasicTable from '@/components/supplier/BasicTable';
// import AdvancedTable from '@/components/supplier/AdvancedTable'; // 表格组件
import { changeRecord } from '@/pages/supplier/constants'
import {
  getChangeLogListBySupplierId, // 通过供应商ID查询操作记录
} from '@/api/supplier/components';
const { TABLE_COLUMNS } = changeRecord

export default {
  components: {
    BasicTable,
    // AdvancedTable,
  },
  props: {
    supplierId: { // 供应商Id
      type: [Number, String],
      default: ''
    },
  },
  data () {
    return {
      fromPageName: '',
      tableInfo: {
        list: [],
        selection: [],
        columns: TABLE_COLUMNS,
        loading: false
      },
      pagination: {
        total: 0,
        current: 1,
        size: 10,
        pages: 0
      },
    }
  },
  computed: {
    ...mapState('supplier/dict', [
      'dictData',
      'sysDictData',
    ])
  },
  created () {
    this.getTableData();
  },
  methods: {
    async getTableData (current = this.pagination.current, size = this.pagination.size) {
      this.tableInfo.loading = true
      const { supplierId } = this
      const { status, result = [] } = await getChangeLogListBySupplierId({ supplierId: `${supplierId}`, current, size })
      this.tableInfo.loading = false
      if (status === '0' && result) {
        const { records: list, current, size, pages, total } = result
        this.pagination = Object.assign(this.pagination, { current, size, pages, total })
        this.tableInfo.list = list
      }
    },
    handlePageChange (current) {
      this.getTableData(current)
    },
    handlePageSizeChange (size) {
      this.getTableData(1, size)
    },
    getDictData (dictId, itemId) {

    },
    getSysDictData (dictId, itemId) {

    }
  },
}
</script>

<style scoped>

</style>
